class Solution
{
public:
    int numOfSubarrays(vector<int> &arr, int k, int threshold)
    {
        int kSum = 0;
        for (int i = 0; i < k; ++i)
        {
            kSum += arr[i];
        }
        int count = 0;
        int kThreshold = k * threshold;
        if (kSum >= kThreshold)
        {
            ++count;
        }
        for (int i = k; i < arr.size(); ++i)
        {
            kSum -= arr[i - k];
            kSum += arr[i];

            if (kSum >= kThreshold)
            {
                ++count;
            }
        }
        return count;
    }
};